
public class Test7 {

        public static void main(String[] args) {
            long start = System.currentTimeMillis();
            String s = "";
            for(int i = 0; i < 10000; ++i){
                s += i;
            }
            long end = System.currentTimeMillis();
            System.out.println(end - start);
            start = System.currentTimeMillis();
            StringBuffer sbf = new StringBuffer("");
            for(int i = 0; i < 10000; ++i){
                sbf.append(i);
            }
            end = System.currentTimeMillis();
            System.out.println(end - start);
            start = System.currentTimeMillis();
            StringBuilder sbd = new StringBuilder();
            for(int i = 0; i < 10000; ++i){
                sbd.append(i);
            }
            end = System.currentTimeMillis();
            System.out.println(end - start);

    }


    public static void main9(String[] args) {
        String str="abc";
        for (int i = 0; i < 5; i++) {
            str=str+'a';
        }
        System.out.println(str);
    }
    public static void main8(String[] args) {
        String str=" aaa aaa   ";
        System.out.println(str.trim());
    }
    public static void main7(String[] args) {
        String str="abcdef";
        System.out.println(str.substring(2));
        System.out.println(str.substring(2,6));
    }
    public static void main6(String[] args) {
        String str = "name=lisi&age=20";
        String[] result = str.split("&");
        for (int i = 0; i < result.length; i++) {
            String[] temp = result[i].split("=");
            System.out.println(temp[0] + " = " + temp[1]);

        }
    }
    public static void main5(String[] args) {
        String str = "192.168.1.1" ;
        String[] result = str.split("\\.") ;
        for(String s: result) {
            System.out.println(s);
        }
    }
    public static void main4(String[] args) {
        String str = "hello world to bit" ;
        String[] result = str.split(" ",2) ; // 按照空格拆分
        for(String str1: result) {
            System.out.println(str1);
        }
    }
    public static void main3(String[] args) {
        String str="aaabbbccc";
        String str1=str.replaceAll("aaa","111");
        String str2=str.replaceFirst("a","p");
        System.out.println(str1);
        System.out.println(str2);

    }
    public static void main2(String[] args) {
        String s = "hello";
        // 字符串转数组
        char[] ch = s.toCharArray();
        for (int i = 0; i < ch.length; i++) {
            System.out.print(ch[i]);
        }
        System.out.println();
         // 数组转字符串
        String s2 = new String(ch);
        System.out.println(s2);
    }

    public static void main1(String[] args) {
        String str1="abc";
        String str2="ABC";
        String str3="Abc";
        System.out.println(str1.toUpperCase());
        System.out.println(str2.toLowerCase());
        System.out.println(str3.toUpperCase());
    }
}
